
Page({

  data: {
    balance: ''
  },
  // 下拉刷新
  onPullDownRefresh: function () {
    // 动态设置导航条标题
    var that = this;
    wx.setNavigationBarTitle({
      title: '请求的数据'
    });
    wx.showNavigationBarLoading(); //在标题栏中显示加载图标
    wx.request({
      url:'https://testsfy.applinzi.com/2.php' ,

      //请求成功的函数处理
      success: function (res) {
        that.setData({
          balance: res.data,
        });
      },
      fail: function (res) {                             //请求失败的处理
        console.log(res.data.msg);
      },
      complete: function () {
        wx.hideNavigationBarLoading();                   //完成停止加载
        // 动态设置导航条标题
        wx.setNavigationBarTitle({
          title: '我的数据'
        });
        wx.stopPullDownRefresh();                       //停止下拉刷新
      }
    })
  },    
  //下拉加载
  onReachBottom: function () {
    console.log('加载更多')
    var that=this;
    wx.request({
      url: 'https://testsfy.applinzi.com/2.php',
      header: {

        'content-type': 'application/json'

      },
      //请求成功的函数处理
      success: function (res) {
        that.setData({
          balance: res.data,
        });
      },
      fail: function (res) {                             //请求失败的处理
        console.log(res.data.msg);
      },
    })
  },
})
